//
//  NSObject+MSChainMaker.m
//  MSDemo
//
//  Created by mac on 2021/6/18.
//

#import "NSObject+MSChainMaker.h"

@interface NSObject ()

@end

@implementation NSObject (MSChainMaker)

- (MSChainMaker *)msChainMaker
{
    return objc_getAssociatedObject(self, _cmd);
}
- (void)setMsChainMaker:(MSChainMaker *)msChainMaker
{
    objc_setAssociatedObject(self, @selector(msChainMaker), msChainMaker, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (instancetype)ms_makeChains:(void(^)(MSChainMaker *make))block
{
    MSChainMaker *chainMaker = self.msChainMaker;
    if (!chainMaker)
    {
        chainMaker =  [[MSChainMaker alloc] init];
        chainMaker.originalObj = self;
        self.msChainMaker = chainMaker;
    }
    block(chainMaker);
    return self;
}

@end
